package observer.weather;

/**
 * @Auther jacob
 * @Date 2020/11/29 10:19
 */
public class CurrentConditionsDisplay implements Observer, DisplayElement {
    private float temperature;
    private float humidity;
    private  Subject weatherData;

    public CurrentConditionsDisplay(Subject weatherData) {
        this.weatherData = weatherData;
        weatherData.registerObserver(this); // 观察者注册到主题中
    }

    public void display() {
        System.out.println("Current conditions: " + temperature + "F degrees and " + humidity + "% humidity ");

    }

    public void update(float tmp, float humidity, float pressure) {
        this.temperature = tmp;
        this.humidity = humidity;
        display();
    }
}
